<?php 
require "vuelta.config.php";

require "vuelta_queries.php";

if(is_logged_in()){
  $db = Vuelta::get_database_connection();

  //all runners
  $runners = get_runners($db);
  //runners chosen by user
  $chosen = get_chosen($db);
  //chosen runner traits
  $top = get_top($db);
  $climber = get_climber($db);
  $sprinter = get_sprinter($db);

  $db->close();
}

?>
<!DOCTYPE html>
<html>
<head>
  <title>Vuelta Tourspel - Overzicht renners</title>
  <meta charset="utf-8">
  <script type="text/javascript"></script>
  <?php Vuelta::css('css/generic.css');?>
  <?php Site::css('header');?>
  <?php Site::css('login');?>
  <?php Vuelta::css('css/overview.css');?>
</head>

<body>
  <?php Site::load('header'); ?>
  <?php Site::load('login'); ?>

    <div class="content">
<?php
  if(!is_logged_in()) {
?>  <p>Je moet ingelogd zijn om deze pagina te bekijken</p> 
<?php
  }
  else {
?>
    <h3>Overzicht gekozen renners Vueltaspel 2011</h3>
    <h5>Selectie</h5>
    <ul id="chosen">
    <?php foreach($chosen as $chosen_one) { ?>
      <li><?=$chosen_one?></li>
    <?php } ?>
    </ul>
    <h5>Klimmer</h5>
    <ul id="climber">
    <?php if(isset($climber)){ ?>
      <li><?=$climber?></li>
    <?php } ?>
    </ul>
    <h5>Sprinter</h5>
    <ul id="sprinter">
    <?php if(isset($sprinter)){ ?>
      <li><?=$sprinter?></li>
    <?php } ?>
    </ul>
    <h5>Top 15</h5>
    <ol id="top">
    <?php for($i = 1; $i < 16; $i++) { ?>
      <li><?=isset($top[$i]) ? $top[$i] : ""?></li>
    <?php } ?>
    </ol>
<?php
  }
?>
    </div>
</body>
</html>
